import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '企业编码',
    align:"center",
    dataIndex: 'companyCode'
  },
  {
    title: '风险分析对象编码',
    align:"center",
    dataIndex: 'hazardCode'
  },
  {
    title: '责任部门',
    align:"center",
    dataIndex: 'hazardDep_dictText'
  },
  {
    title: '责任人',
    align:"center",
    dataIndex: 'hazardLiablePerson_dictText'
  },
  {
    title: '重大危险源名称',
    align:"center",
    dataIndex: 'name'
  },
  {
    title: '重大危险源级别',
    align:"center",
    dataIndex: 'seriousHazard_dictText'
  },
  {
    title: '主要负责人',
    align:"center",
    dataIndex: 'main_dictText'
  },
  {
    title: '技术负责人',
    align:"center",
    dataIndex: 'technology_dictText'
  },
  {
    title: '操作负责人',
    align:"center",
    dataIndex: 'operate_dictText'
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "企业编码",
    field: "companyCode",
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "风险分析对象编码",
    field: "hazardCode",
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "责任部门",
    field: "hazardDep",
    component: 'JSelectDept',
    //colProps: {span: 6},
  },
  {
    label: "责任人",
    field: "hazardLiablePerson",
    component: 'JSelectUser',
    //colProps: {span: 6},
  },
  {
    label: "重大危险源名称",
    field: "name",
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "重大危险源级别",
    field: "seriousHazard",
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"serious_hazard"
    },
    //colProps: {span: 6},
  },
  {
    label: "工艺类型",
    field: "processType",
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"processType"
    },
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '企业编码',
    field: 'companyCode',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入企业编码!'},
      ];
     },
  },
  {
    label: '风险分析对象编码',
    field: 'hazardCode',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入风险分析对象编码!'},
      ];
     },
  },
  {
    label: '责任部门',
    field: 'hazardDep',
    component: 'JSelectDept',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入责任部门!'},
      ];
     },
  },
  {
    label: '责任人',
    field: 'hazardLiablePerson',
    component: 'JSelectUser',
    componentProps:{
      labelKey:'realname',
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入责任人!'},
      ];
     },
  },
  {
    label: '重大危险源名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入重大危险源名称!'},
      ];
     },
  },
  {
    label: '重大危险源级别',
    field: 'seriousHazard',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"serious_hazard"
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入重大危险源级别!'},
      ];
     },
  },
  {
    label: '工艺类型',
    field: 'processType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"processType"
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入工艺类型!'},
      ];
     },
  },
  {
      label: '主要负责人',
      field: 'main',
      component: 'JSelectUserByDept',
      componentProps:{
        labelKey: 'realname',
      },
    },
    {
      label: '技术负责人',
      field: 'technology',
      component: 'JSelectUserByDept',
      componentProps:{
        labelKey: 'realname',
      },
    },
    {
      label: '操作负责人',
      field: 'operate',
      component: 'JSelectUserByDept',
      componentProps:{
        labelKey: 'realname',
      },
    },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
	field: 'id',
	component: 'Input',
	show: false
  },
];

//子表列表数据
export const tbBaseRiskUnitColumns: BasicColumn[] = [
  {
    title: '风险分析单元名称',
    align:"center",
    dataIndex: 'riskUnitName'
  },
  {
    title: '创建日期',
    align:"center",
    dataIndex: 'createTime'
  },
  
];
//子表表单数据
export const tbBaseRiskUnitFormSchema: FormSchema[] = [
  // TODO 子表隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
  {
    label: '风险分析单元名称',
    field: 'riskUnitName',
    component: 'Input',
  },
];

// 高级查询数据
export const superQuerySchema = {
  companyCode: {title: '企业编码',order: 0,view: 'text', type: 'string',},
  hazardCode: {title: '风险分析对象编码',order: 1,view: 'text', type: 'string',},
  hazardDep: {title: '责任部门',order: 2,view: 'sel_depart', type: 'string',},
  hazardLiablePerson: {title: '责任人',order: 3,view: 'sel_user', type: 'string',},
  name: {title: '重大危险源名称',order: 4,view: 'text', type: 'string',},
  main: {title: '主要负责人',order: 3,view: 'sel_user', type: 'string',},
  technology: {title: '技术负责人',order: 3,view: 'sel_user', type: 'string',},
  operate: {title: '操作负责人',order: 3,view: 'sel_user', type: 'string',},
};
